<?php
/**
 * Pipahr
 *
 * @author Randy Zhao
 * @copyright 2013 pipahr.com
 */
defined('_JEXEC') or die;

// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();

if (isDevMode()) {
   OCP\Util::addStyle('interview', 'interview');
   OCP\Util::addScript('interview', 'interview');
} else {
   OCP\Util::addStyle('static', 'interview');
   OCP\Util::addScript('static', 'jquery/ui/jquery.ui.datepicker.min');
   OCP\Util::addScript('static', 'apps/interview.interview.min');
}

$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");

$idarr = array();
foreach ($_['interview'] as $ques) {
   $idarr[] = $ques->iid;
}
$field_json = json_encode($idarr);

$company_url = PInterviewHelper::getCompanyUrl($_['basicInfo']->sub_domain,0);
$company_url = $company_url ? $company_url."?utp=nocp" : '';
?>

<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('interview/js', 'interview.php'));?>"></script>

<div class="row-fluid">
   <div class="span12">
      <div class="company_info_box clearfix">
         <div class="company_showimg pull-left">
            <?php if (!empty($company_url)) : ?>
            <a href="<?=$company_url?>" target="_blank">
               <img src="<?php echo PCompanyHelper::showCompanyAvatar($_['basicInfo']->avatar, $_['basicInfo']->avatarapproved);?>" class="cpy_logo_mid"/>
            </a>
            <?php else : ?>
            <img src="<?php echo PCompanyHelper::showCompanyAvatar($_['basicInfo']->avatar, $_['basicInfo']->avatarapproved);?>" class="cpy_logo_mid"/>
            <?php endif;?>
         </div>
         <div class="company_showinfo">
            <h4 class="yahei">
               <?php if (!empty($company_url)) : ?>
               <a href="<?=$company_url?>" target="_blank"><?=$_['basicInfo']->comp_name?></a>
               <?php else : ?>
               <?=$_['basicInfo']->comp_name?>
               <?php endif;?>
               <i class="<?php echo $_['basicInfo']->validated == EMPLOYER_VALIDATED ? "is_approve" : "not_approve";?>"></i>
            </h4>
            <ul class="company_listinfo medium">
               <li>行业：<?php echo $_['basicInfo']->industry ? JText::_($_['basicInfo']->industry) : '未填写';?></li>
               <li>性质：<?php echo $_['basicInfo']->comp_type ? JText::_($_['basicInfo']->comp_type) : '未填写';?></li>
               <li>规模：<?php echo $_['basicInfo']->size_type ? JText::_($_['basicInfo']->size_type) : '未填写';?></li>
               <li>所在地区：<?php echo !empty($_['basicInfo']->cstate) || !empty($_['basicInfo']->ccity) ? $_['basicInfo']->cstate.$_['basicInfo']->ccity : "未填写";?></li>
            </ul>
         </div>
      </div>
   </div>
</div>

<div class="container">
   <div class="row-fluid">
      <div class="span12 blackbottom">
         <div class="company_position_show clearfix">
            招聘职位：<?php echo $_['basicInfo']->job_title ? $_['basicInfo']->job_title : '未填写';?> |
            工作城市：<?php echo ($_['basicInfo']->state || $_['basicInfo']->city) ? ($_['basicInfo']->state == $_['basicInfo']->city ? $_['basicInfo']->state : $_['basicInfo']->state.' '.$_['basicInfo']->city) : '未填写'; ?> |
            薪水：<?php echo $_['basicInfo']->salary_type ? $_['basicInfo']->salary_type : '未填写';?> |
            经验：<?php echo $_['basicInfo']->exp_name ? JText::_($_['basicInfo']->exp_name) : '未填写';?> |
            招聘人数：<?php echo $_['basicInfo']->num_needed ? $_['basicInfo']->num_needed : '未填写';?>
         </div>
      </div>
   </div>
</div>

<div class="container">
   <div class="row-fluid">
      <div class="span12">
         <div class="company_qes_fixed large clearfix"><?=$_['basicInfo']->job_title;?>职位线上竞聘</div>
      </div>
   </div>
</div>

<div class="row-fluid hr_oneconn_margin">
   <div class="span12 oneconn_box">
      <div class="lgrg_form">
         <div class="hr_inputinfo">
            <div class="hr_teststep hr_teststep_nomargin">
               <table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                     <td width="" class="medium test_ok"><span class="teststep_1"><i></i>核对身份</span></td>
                     <td width="22" class="arrow_blue_blue"></td>
                     <td width="" class="medium test_ok"><span class="teststep_2"><i></i>完善信息</span></td>
                     <?php if ($_['isPaperSet'] && $_['isInviteToken']) :?>
                     <td width="22" class="arrow_blue_grey"></td>
                     <td width="" class="medium"><span class="teststep_3"><i></i>线上笔试</span></td>
                     <td width="22" class="arrow_grey_grey"></td>
                     <?php else:?>
                     <td width="22" class="arrow_blue_grey"></td>
                     <?php endif;?>
                     <td width="" class="medium"><span class="teststep_4"><i></i>完成&nbsp;&nbsp;&nbsp;</span></td>
                  </tr>
               </table>
            </div>
            <div class="hr_testerinfo_input">
               <p style="color:#ff6600;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请完善以下信息，以便人事主管了解您的最新近况</p>
               <div class="hr_testinfo_form">
                  <form action="<?php echo OC_Helper::linkToRoute("interview_postinterview");?>" method="post" name="interviewform" id="interviewform">

                  <?php foreach ($_['interview'] as $k => $v):?>
                     <?php if($v->alias == 'MORESKILL') continue; ?>
                     <?php if ($v->choices && $v->alias != 'SKILL'):?>
                        <?php $vchoices = json_decode($v->choices);?>
                        <?php if ($v->alias == 'SEX'):?>
                           <?php if (!empty($_['jseeker_info']->sex)) : ?>
                           <input type="hidden" name="<?=$v->alias?>" value="<?=$_['jseeker_info']->sex?>"/>
                           <?php else: ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label"><?=$v->text?><?php echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：</label>
                              <div class="hr_controls">
                                 <select class="input-medium required" name="<?=$v->alias?>">
                                    <?php foreach ($vchoices as $key => $value):?>
                                    <option value="<?=$key?>" <?php echo $_['jseeker_info']->sex == $key ? "selected = 'selected'" : "";?>><?=$value?></option>
                                    <?php endforeach;?>
                                 </select>
                              </div>
                           </div>
                           <?php endif; ?>
                        <?php elseif ($v->alias == 'DEGREE') : ?>
                           <?php if (!empty($_['jseeker_info']->degree)) : ?>
                           <?php
                           foreach ($vchoices as $key => $value) {
                              if ($_['jseeker_info']->degree == $value) {
                                 $_['jseeker_info']->degree = $key;
                              }
                           }
                           ?>
                           <input type="hidden" name="<?=$v->alias?>" value="<?=$_['jseeker_info']->degree?>"/>
                           <?php else: ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label"><?=$v->text?><?php echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：</label>
                              <div class="hr_controls">
                                 <select class="input-medium required" id="<?=$v->alias?>" name="<?=$v->alias?>">
                                    <option value="">--请选择--</option>
                                    <?php foreach ($vchoices as $key => $value):?>
                                    <option value="<?=$key?>"><?=$value?></option>
                                    <?php endforeach;?>
                                 </select>
                              </div>
                           </div>
                           <?php endif; ?>
                        <?php elseif ($v->alias == 'SCHOOL_LEVEL') : ?>
                           <input type="hidden" name="<?=$v->alias?>" value="<?php echo intval($_['jseeker_info']->level);?>"/>
                        <?php elseif ($v->alias == 'LANG') : ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label"><?=$v->text?><?php echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：</label>
                              <div class="hr_controls">
                                 <select class="input-medium required" name="<?=$v->alias?>[<?=$v->iid?>]">
                                    <option value="0">不会</option>
                                    <?php
                                       $item = 0;
                                       foreach ($vchoices as $key => $value):
                                          $selected = $item==0 ? 'selected="selected"' : '';
                                          $item++;
                                    ?>
                                    <option <?=$selected?> value="<?=$key?>"><?=$value?></option>
                                    <?php endforeach;?>
                                 </select>
                              </div>
                           </div>
                        <?php elseif ($v->alias == 'MARRIAGE') : ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                              <?=$v->text?>：
                              </label>
                              <div class="hr_controls">
                                 <select class="input-medium required" name="<?=$v->alias?>">
                                    <option value="0">--请选择--</option>
                                    <?php foreach ($vchoices as $key => $value): ?>
                                    <option value="<?=$key?>"><?=$value?></option>
                                    <?php endforeach;?>
                                 </select>
                              </div>
                           </div>
                        <?php else: ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label"><?php echo $v->alias == 'LOCATION' ? str_ireplace('$city', str_replace('-', '', $v->expected_answer), $v->text) : $v->text;?><?php echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：</label>
                              <div class="hr_controls">
                                 <select class="input-medium required" name="<?=$v->alias?>">
                                    <option value="">--请选择--</option>
                                    <?php foreach ($vchoices as $key => $value): ?>
                                    <option value="<?=$key?>"><?=$value?></option>
                                    <?php endforeach;?>
                                 </select>
                              </div>
                           </div>
                        <?php endif;?>
                     <?php else: ?>
                        <?php if ($v->alias == 'INDUSTRY'):?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                                 <?=$v->text?><?php echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：
                              </label>
                              <div class="hr_controls">
                                 <?php echo JobHelper::getSelectIndustry($v->alias, '', 0, '', true, false, array(array('value'=>0,'text'=>'应届毕业生')));?>
                              </div>
                           </div>
                        <?php elseif ($v->alias == 'AGE') : ?>
                           <?php if (!isNullDate($_['jseeker_info']->dateofbirth)) : ?>
                           <input type="hidden" name="<?=$v->alias?>" value="<?=$_['jseeker_info']->dateofbirth?>"/>
                           <?php else: ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                                 <?=$v->text?>&nbsp;<?php echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：
                              </label>
                              <div class="hr_controls">
                                 <input type="text" class="input-small required date" id="birthday" name="<?=$v->alias?>" value="" readonly="readonly" style="cursor:pointer"/>
                              </div>
                           </div>
                           <?php endif; ?>
                        <?php elseif ($v->alias == 'WORK_EXP') : ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                                 <?=$v->text?>（年限）：
                              </label>
                              <div class="hr_controls">
                                 <input type="text" name="<?=$v->alias?>" class="input-mini exp_group <?php echo $v->match_rule == "LESS" || $v->match_rule == "GREATER" ? '{digits:true, messages: {digits:\'只能输入正整数和零\'}}' : ''?>"/>&nbsp;年
                                 <input type="text" name="WORK_EXP_MONTHS" class="input-mini exp_group {digits:true, messages:{digits:'只能输入正整数和零'}}" id="WORK_EXP_MONTHS"/>&nbsp;个月&nbsp;(不含实习)
                              </div>
                           </div>
                        <?php elseif ($v->alias == 'SALARY') : ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                                 <?=$v->text?>&nbsp;<?echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：
                              </label>
                              <div class="hr_controls">
                                 <input type="text" name="<?=$v->alias?>" class="input-small {required:true,digits:true,min:1,maxlength:10,messages:{digits:'只能输入正整数', min:'只能输入正整数',maxlength:'请输入正确的期望月薪'}}"/>
                              </div>
                           </div>
                        <?php elseif ($v->alias == 'SKILL') : ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                                 <span title="<?=(compact_strlen($v->text)>9?$v->text:'')?>"><?=strmaxtextlen($v->text,9)?></span>&nbsp;实际工作经验<?echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：
                              </label>
                              <div class="hr_controls skill_ctl">
                                 <select id="skill<?=$v->iid?>" class="exp_select required" name="SKILL_LEVEL[<?=$v->iid?>]" data-iid="<?=$v->iid?>"><option value=''>--选择熟练度--</option><option value=0>无</option><option value=<?=PInterviewHelper::SKILL_LEVEL_GENERALE ?>>普通</option><option value=<?=PInterviewHelper::SKILL_LEVEL_SKILLED ?>>熟练</option><option value=<?=PInterviewHelper::SKILL_LEVEL_PROFICIENTE ?>>精通</option></select>
                                 <input id="skill<?=$v->iid?>" type="text" name="<?=$v->alias?>[<?=$v->iid?>]" class="input-small skill<?=$v->iid?> required <?php echo $v->match_rule == "LESS" || $v->match_rule == "GREATER" ? '{digits:true,min:1,messages:{digits:\'只能输入正整数\',min:\'只能输入正整数\'}}' : ''?>"/>
                                 <label class="error" style="display:none;" generated="true" for="skill<?=$v->iid?>">该项必须填写</label>
                                 <span>个月</span>
                              </div>
                           </div>
                        <?php else: ?>
                           <div class="hr_form_group clearfix">
                              <label class="hr_name_label">
                                 <?=$v->text?>&nbsp;<?echo $v->unit_name ? '&nbsp;('.$v->unit_name.')' : ''?>：
                              </label>
                              <div class="hr_controls">
                                 <input type="text" name="<?=$v->alias?>" class="input-small required <?php echo $v->match_rule == "LESS" || $v->match_rule == "GREATER" ? '{digits:true, messages: {digits:\'只能输入正整数和零\'}}' : ''?>"/>
                              </div>
                           </div>
                        <?php endif;?>
                     <?php endif;?>
                  <?php endforeach;?>
                     <div id="skilldiv">
                     </div>
                     
                     <div class="jos_ownaddskill medium" id="addskill"><a href="javascript:;">添加技能<i class="addicon"></i></a></div>

                  <div class="hr_form_group clearfix">
                     <div class="hr_controls">
                        <input class="ppp_bluebtn" type="submit" value="提 交" id="submit_button" disabled="disabled"/>
                        <span class="medium">提交后此信息将不可更改</span>
                        <div id='errormsg' class='error' style='margin-top: 10px; display:none;'></div>
                        <input type="hidden" name="token" value="<?=$_['token']?>"/>
                        <input type="hidden" name="employer_id" value="<?=$_['basicInfo']->employer_id?>"/>
                        <input type="hidden" name="job_id" value="<?=$_['basicInfo']->job_id?>"/>
                        <input type="hidden" name="jobseeker_id" value="<?=$_['basicInfo']->jobseeker_id?>"/>
                        <input type="hidden" name="session_id" value="0" id="session_id"/>
                        <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
                     </div>
                  </div>
                  </form>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>
